/*
 * Copyright 2006-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.martinimix.webflow.accessor;

import org.springframework.webflow.execution.RequestContext;

import com.bluemartini.dna.BusinessObject;
import com.bluemartini.dna.BusinessObjectArray;
import com.bluemartini.webconnect.WebConnect;

/**
 * Provides a flow object accessor capable of retrieving objects from 
 * Blue Martini form data.
 * 
 * @author Scott Rossillo
 *
 */
public class FormDataCartAccessor extends FormDataBusinessObjectAccessor implements FlowCartAccessor {
	
	/**
	 * Returns the Blue Martini cart header from the given context's session.
	 * 
	 * @param context the <code>RequestContext</code> from which to retrieve
	 * the cart header
	 * 
	 * @return a <code>BusinessObject</code> representing the card header
	 * 
	 */
	public BusinessObject getCartHeader(RequestContext context) {
		return super.getBusinessObject(WebConnect.SESSION_CART_HEADER, context);
	}
	
	/**
	 * Returns the Blue Martini cart item array from the given context's session.
	 * 
	 * @param context the <code>RequestContext</code> containing the session whose
	 * cart items should be returned
	 * 
	 * @return a <code>BusinessObjectArray</code> containing the cart items from
	 * the given <code>context</code> if no cart items were found
	 * 
	 */
	public BusinessObjectArray getCartItems(RequestContext context) {
		return 	super.getFormData(context).getBusinessObjectArray(WebConnect.SESSION_CART_ITEM_ARRAY);
	}

}
